package org.pocketmoney.gui.model;

import java.util.LinkedList;
import java.util.List;

import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;

import org.pocketmoney.core.entities.record.IRecord;

public class RecordTypeComboBoxModel implements ComboBoxModel<String>
{

	private static final RecordTypeComboBoxModel inst = new RecordTypeComboBoxModel();
	private String[] values = {IRecord.TYPE_CREDIT, IRecord.TYPE_SALARY, IRecord.TYPE_PURCHASE, IRecord.TYPE_TRIBUTE};
	private Object selectedItem = IRecord.TYPE_PURCHASE;
	private List<ListDataListener> listeners = new LinkedList<>();
	
	private RecordTypeComboBoxModel()
	{
	}
	
	public static RecordTypeComboBoxModel getInst()
	{
		return inst;
	}
	
	@Override
	public int getSize()
	{
		return values.length;
	}

	@Override
	public String getElementAt(int index)
	{
		return values[index];
	}

	@Override
	public void addListDataListener(ListDataListener l)
	{
		listeners.add(l);
	}

	@Override
	public void removeListDataListener(ListDataListener l)
	{
		listeners.remove(l);
	}

	@Override
	public void setSelectedItem(Object anItem)
	{
		selectedItem = anItem;
	}

	@Override
	public Object getSelectedItem()
	{
		return selectedItem;
	}

}
